package cn.itcast.bos.web.action.take_delivery;

import cn.itcast.bos.domain.take_delivery.Order;
import cn.itcast.bos.service.base.OrderService;
import cn.itcast.bos.util.base.BaseAction;
import com.google.common.collect.HashBiMap;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Scope("prototype")
@Namespace("/")
@ParentPackage("json-default")
public class OrderAction extends BaseAction<Order> {
    @Autowired
    private OrderService orderService;
    @Action(value = "order_findOrderByOrderNum",results = {
            @Result(name = "success",type = "json")
    })
    public String findOrderByOrderNum(){
        Order order = orderService.findOrderByOrderNum(model.getOrderNum());
        Map<String,Object> result = new HashMap<>();
        if (order == null) {
            result.put("success",false);
        }else{
            result.put("success",true);
            result.put("orderData",order);
        }
        System.out.println(order);
        ServletActionContext.getContext().getValueStack().push(result);
        return SUCCESS;
    }
}
